This invention relates generally to computer-implemented methods for compressing files containing graphics instructions. More specifically, the invention relates to methods for compressing instruction files, known as journal files or metafiles, used in conjunction with Microsoft Windows(copyright) graphics display interfaces.
Graphical output under the Microsoft Windows 3.x(copyright), Windows95(copyright), and Windows NT(copyright) operating systems is generally accomplished through calls to operating system finctions. The operating system components used for carrying out graphics instructions are collectively referred to as the graphic device interface or GDI.
The Windows(copyright) GDI uses dynamically created objects or resources for carrying out drawing operations. Resources are classified into four different categories or classes: pens, brushes, palettes and fonts. One resource from each class can be currently selected at any given time. Different GDI resources are is used to perform various types of drawing operations.
GDI drawing instructions can be used to form a variety of shapes or images, such as lines, arcs, regions, ellipses, polygons, rectangles, and bitmaps. Drawing a straight line is an example of a simple operation that can be performed with GDI instructions. To draw a line, a pen is created, selected, used, and then deleted. This involves four different instructions or GDI function calls: CREATEPEN, SELECTOBJECT, LINETO, and DELETEOBJECT.
GDI drawing instructions operate with reference to a two-dimensional display mediumxe2x80x94commonly a computer""s CRT. Two-dimensional coordinate pairs are thus used in many GDI instructions to specify locations for different types of graphics shapes and entities.
In addition to providing a convenient way to create device-independent graphics images, the Window(copyright) GDI can be used to create data files for storing such images. Rather than storing the images in bit-mapped format, they are stored as an ordered sequence of GDI instructions which are later xe2x80x9cplayedxe2x80x9d to create an actual display image. The Windows(copyright) GDI contains functions for recording and storing GDI instructions in such files, which are referred to as journal files in general and as xe2x80x9cmetafilesxe2x80x9d in the Windows(copyright) environment. A metafile is simply a collection of GDI commands that creates desired text or images. Metafiles take up less space than bitmaps. In addition, they are more device-independent than bitmaps. They are also scalable in size, in that sizes and positions are specified in terms of an output frame that can be mapped to a different size during playback. For, these reasons, metafiles provide convenient storage for images that appear repeatedly in an application or need to be moved from one application to another.
To generate a metafile, a Windows(copyright) application creates a special device context that sends GDI commands to a metafile for storage. The application can later play back the metafile and display the image. During playback, the GDI breaks the metafile down into records and executes the instruction defined by each record.
A metafile consists of two pertinent parts: a header and a list of records. The header contains a description of the size of the metafile, the number of drawing resources it uses, and other information. Each metafile record contains a header, a GDI instruction, and its arguments.
GDI finctions and metafiles will be familiar to those accustomed to programming in the Windows(copyright) environment. For more information regarding these subjects, refer to the Windows 3.1(copyright), Windows95(copyright) and Windows NT(copyright) Programming Manuals, available from Microsoft Corporation of Redmond, Wash. These references are hereby incorporated by reference.
While metafiles offer an attractive alternative to bit-mapped files, further size reduction would be welcomedxe2x80x94particularly in the context of newer consumer-oriented applications which attempt to utilize graphical user interfaces to a degree that has previously not been attempted. The invention described below meets this need, compressing the data contained in metafiles by ratios not previously attainable.
A compression program receives individual instructions of an original journal file, processes the instructions, and writes them to a processed journal file. If a particular instruction has one or more arguments that can be inferred, the instruction is revised by replacing its record type indicator with a substitute record type indicator and removing the one or more arguments that can be inferred.
When subsequently playing back the instructions of the processed journal file, substitute record type indicators are recognized and replaced by the original record type indicators. In addition, the original arguments are inferred and replaced.